package rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * @author Xewee.Zhiwei.Wang
 * @version 2011-10-11 上午09:27:38
 */
public class RemoteClient {
	/**
	 * @author Xewee.Zhiwei.Wang
	 * @version 2011-10-11 上午09:27:38
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			// 在RMI服务注册表中查找名称为remoteInterface的对象，并调用其上的方法
			ArithmeticRemoteInterface remoteInterface = (ArithmeticRemoteInterface) Naming
					.lookup("rmi://localhost:8888/Arithmetic");
			System.out.println("远程加法计算>>>> 1011 + 1000 = " + remoteInterface.add(1011, 1000));
			System.out.println("远程减法计算>>>> 1011 - 1000 = " + remoteInterface.sub(1011, 1000));
			System.out.println("远程乘法计算>>>> 1011 * 1000 = " + remoteInterface.mul(1011, 1000));
			System.out.println("远程除法计算>>>> 1011 / 1000 = " + remoteInterface.div(1011, 1000));
		} catch (NotBoundException e) {
			e.printStackTrace();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
}
